package com.yiheima.extendsdemo2;

public class Test2 {
    public static void main(String[] args) {
        student s = new student("Tom", 20, "Male");
        System.out.println(s);//默认调用Object的toString方法,可以重写了toString方法,打印出自定义的字符串
    }

    static  class student extends  Object {
        private String name;
        private int age;
        private String gender;
        public student() {
        }
        public student(String name, int age, String gender) {
            this.name = name;
            this.age = age;
            this.gender = gender;
        }
        @Override
        public String toString() {
            return "student{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    ", gender='" + gender + '\'' +
                    '}';
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public String getGender() {
            return gender;
        }

        public void setGender(String gender) {
            this.gender = gender;
        }
    }
}
